<?php

namespace Database\Seeders;

use App\Models\User;
use Faker\Factory;
use Illuminate\Database\Seeder;
use Hash;
use Str;
use Illuminate\Support\Facades\DB;

class UserSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Factory::create('zh_CN');
        $rows = [];
        for ($i = 0; $i < 20; $i++) {
            $rows[] = [
                'name' => $faker->name,
                'password' => md5($faker->password),
                'email' => $faker->email,
                'mobile' => $faker->phoneNumber,
                'email_verified_at' => now(),
                'remember_token' => Str::random(10),
            ];
        }
        DB::table('users')->insert($rows);

        $user = User::find(1);
        $user->name = '袁大叔';
        $user->mobile = 18090900235;
        $user->password = Hash::make('admin888');
        $user->save();

        $user = User::find(2);
        $user->name = '邓小妞';
        $user->mobile = 18180191182;
        $user->password = Hash::make('admin888');
        $user->save();

    }
}
